package com.markchu.admin.web;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class JsoupExample {
    public static void main(String[] args) {
        String url = "https://www.dianping.com/shanghai/ch95"; // 要爬取的网页 URL
        try {
            Document doc = Jsoup.connect(url).get();
            Elements elements = doc.select("#shop-all-list li"); //
            System.out.println(elements.text()); // 输出<h1>元素的文本内容
            for (Element element : elements) {
                System.out.println(element.text()); // 输出<h1>元素的文本内容
            }
            String content = doc.html();
            System.out.println(content);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}